<template>
      <div>
            <el-scrollbar>
                  <el-table :data="tableData">
                        <el-table-column label="被申请人" prop="personb"/>
                        <el-table-column label="案由详情" prop="content" showOverflowTooltip="true"/>
                        <el-table-column label="案件类型" prop="species">
                              <template v-slot="scope">
                                    <el-tag
                                              :type="scope.row.species=== 0 ? 'primary' :(scope.row.species=== 1 ? 'success': 'danger' )"
                                              disable-transitions
                                    >{{
                                                scope.row.species === 0 ? '刑事案件' : (scope.row.species === 1 ? '民事案件' : '行政案件')
                                          }}
                                    </el-tag
                                    >
                              </template>
                        </el-table-column>
                        <el-table-column label="状态" prop="state">
                              <template v-slot="scope">
                                    <el-tag
                                              :type="scope.row.state=== 0 ? 'primary' :(scope.row.state=== 1 ? 'success': 'danger' )"
                                              disable-transitions
                                    >{{ scope.row.state === 0 ? '未受理' : (scope.row.state === 1 ? '已指派' : '已结案') }}
                                    </el-tag
                                    >
                              </template>
                        </el-table-column>
                        <el-table-column label="操作" prop="operate">
                              <template v-slot="scope">
                                    <el-button size="small" type="warning" @click="ok(scope.row)">确认结案</el-button>
                                    <el-button size="small" type="success" @click="del(scope.row.id)">删除记录</el-button>
                              </template>
                        </el-table-column>
                  </el-table>
            </el-scrollbar>
      </div>
</template>

<script>
export default {
      name: "myAid",
      data() {
            return {
                  tableData:[],
                  lawcase: {
                        id: '',
                        personA: '',
                        cardA: '',
                        personB: '',
                        cardB: '',
                        content: '',
                        state: '',
                        species: '',
                        DT: '',
                        flag: ''
                  },
            }
      },
      methods: {
            init() {
                  this.user = JSON.parse(sessionStorage.getItem('CurUser'))
            },
            loadGet() {
                  this.$axios.get('http://localhost:8088/lawcase/findByUser?user=' + this.user.name).then(res => res.data).then(res => {
                        console.log(res)
                        if (res.code === 200) {
                              // alert("是200")
                              this.tableData = res.data
                              console.log("assistance===" + res.data)
                        } else {
                              alert("不是200")
                        }
                  })
            },
            ok(row){
                  this.$nextTick(() => {
                        this.lawcase = row
                  })
                  this.lawcase.state=2
                  this.$axios.post('http://localhost:8088/lawcase/update', this.lawcase).then(res => {
                        console.log("======"+res)
                        if (res.code !== 200) {
                              this.$message({
                                    message: 'Congrats, this is a success message.',
                                    type: 'success',
                              })
                              this.loadGet()
                        }
                  })
            }
      },
      created() {
            this.init()
            this.loadGet()
      }
}
</script>

<style scoped>

</style>